<template>
  <div class="head">
    <van-nav-bar title="商品详情" left-text="返回"  left-arrow @click-left="onClickLeft" >
      <template #right >
        <div class="right" >
          <van-icon name="ellipsis" />
          <van-icon name="share-o" />
        </div>
      </template>
    </van-nav-bar>

    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服" dot />
      <van-goods-action-icon icon="cart-o" text="购物车"  @click="onClickCar"/>
      <van-goods-action-icon icon="shop-o" text="店铺" badge="12" />
      <van-goods-action-button type="warning" text="加入购物车" @click="onClickCar" />
      <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action>
    <div class="product" >
      <div class="product_r">
        <img :src="partslist.product" alt="" />
        <div class="rong">
          <div class="name">{{ partslist.name }}</div>
          <div class="price">￥{{ partslist.price }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import {Parts, Phone,TvList,PcList,TravelWear,Appliance,Smart} from "@/config/http";
import Vue from 'vue';
import { Icon } from 'vant';

Vue.use(Icon);
export default {
  data() {
    return {
      partslist:{}
    };
  },

  methods: {
    //返回上一个页面
    onClickLeft() {
      this.$router.go(-1);
    },
    // 加入购物车
    onClickCar() {
      this.$router.push("/car");
    },
    parts() {
      let id = this.$route.query.id;
      console.log(id);
      axios.get(Parts).then((res) => {
        this.partslist = res.data[id-1];
        console.log(this.partslist) ;
      });
    },
    phone() {
      let id = this.$route.query.id;
      console.log(id);
      axios.get(Phone).then((res) => {
        this.partslist = res.data[id-1];
        console.log(this.partslist) ;
      });
    },
    tvlist() {
      let id = this.$route.query.id;
      console.log(id);
      axios.get(TvList).then((res) => {
        this.partslist = res.data[id-1];
        console.log(this.partslist) ;
      });
    },
    pclist() {
      let id = this.$route.query.id;
      console.log(id);
      axios.get(PcList).then((res) => {
        this.partslist = res.data[id-1];
        console.log(this.partslist) ;
      });
    },
    travelwear() {
      let id = this.$route.query.id;
      console.log(id);
      axios.get(TravelWear).then((res) => {
        this.partslist = res.data[id-1];
        console.log(this.partslist) ;
      });
    },
    appliance() {
      let id = this.$route.query.id;
      console.log(id);
      axios.get(Appliance).then((res) => {
        this.partslist = res.data[id-1];
        console.log(this.partslist) ;
      });
    },
    smart() {
      let id = this.$route.query.id;
      console.log(id);
      axios.get(Smart).then((res) => {
        this.partslist = res.data[id-1];
        console.log(this.partslist) ;
      });
    },
  },
  created() {
    this.parts();
    this.appliance();
  },
};
</script>
<style scoped>
html,body{
  height: 100%;
}
.van-nav-bar {
  background-color: red;
}
.custom-title {
  margin-right: 4px;
  vertical-align: middle;
}

.search-icon {
  font-size: 16px;
  line-height: inherit;
}

.eagg {
  position: relative;
  top: -459px;
  right: 0px;
}
.van-grid {
  margin-top: 20px;
}

.nav {
  width: 100%;
  height: 50px;
  background-color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  overflow: hidden;
}
.logo {
  width: 30px;
  margin: 20px 20px;
  float: left;
}
.logo img {
  width: 100%;
}

.van-swipe img {
  width: 100%;
  height: 220px;
}
.homepage {
  overflow: hidden;
  padding-bottom: 40px;
}
.product {
  margin: 0 20px;
  /* margin-top: 97px; */
  /* margin-left: 40px; */
  width:335px; 
   height:300px;
  /* background: #ccc; */
}
.product .product_r {
  width: 40%;
  float: left;
  margin-top: 30px;
  margin-left: 20px;
}
.product .product_r img {
  width: 100%;
  height: 100%;
  display: block;
  margin: auto;
  text-align: center;
}
.product .product_r .rong {
  width: 100%;
  margin-top: 20px;
}
.product .product_r .rong .name {
  /* width: 80px; */
  /* text-align: center; */
  /* overflow: hidden; */
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 20px 0;
}
.product .product_r .price {
  margin-top: 10px;
  text-align: center;
  color: red;
  margin: 20px 0px;
  font-size: 20px;
}
.van-list {
  padding-bottom: 40px;
}
.van-image {
  width: 10em;
  height: 10em;
  background: antiquewhite;
}
.van-grid-item__content {
  background-color: bisque;
}
</style>
